package com.baidu.logindemos.utils

import android.app.Activity
import android.content.Context
import android.view.View
import android.view.inputmethod.InputMethodManager

/**
 * object 单例对象
 *    里面的属性和方法都是静态 类名直接调用
 *    如果自己的功能不需要属性
 */
class KeyBoardUtil private constructor(){
    private lateinit var inputMethodManager: InputMethodManager
    companion object{
        val instance: KeyBoardUtil by lazy { KeyBoardUtil() }
    }

    fun init(context: Context){
        inputMethodManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
    }

    fun show(view:View){
        inputMethodManager.showSoftInput(view, 0)
    }

    fun hide(view: View){
        inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
    }
}